home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / Src / Ch1 / Bars2.frm (.txt) < prev    next >
Visual Basic Form  |  1999-03-14  |  1KB  |  47 lines

  1. VERSION 5.00
  2. Begin VB.Form frmBars2 
  3.    Caption         =   "Bars2"
  4.    ClientHeight    =   3195
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4680
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   3195
  10.    ScaleWidth      =   4680
  11.    StartUpPosition =   3  'Windows Default
  12. Attribute VB_Name = "frmBars2"
  13. Attribute VB_GlobalNameSpace = False
  14. Attribute VB_Creatable = False
  15. Attribute VB_PredeclaredId = True
  16. Attribute VB_Exposed = False
  17. Option Explicit
  18. Private Const NUM_VALUES = 7
  19. Private DataValue(1 To NUM_VALUES) As Integer
  20. ' Create some random data.
  21. Private Sub Form_Load()
  22. Dim i As Integer
  23.     Randomize
  24.     For i = 1 To NUM_VALUES
  25.         DataValue(i) = Rnd * 100
  26.     Next i
  27. End Sub
  28. ' Draw the bar chart.
  29. Private Sub Form_Paint()
  30. Dim i As Integer
  31.     ' Define the custom coordinate system.
  32.     ScaleLeft = 0
  33.     ScaleWidth = NUM_VALUES + 2
  34.     ScaleTop = 110
  35.     ScaleHeight = -120
  36.     ' Clear the form.
  37.     Cls
  38.     ' Draw the bar chart.
  39.     For i = 1 To NUM_VALUES
  40.         ' Pick a new fill style.
  41.         FillStyle = i Mod 8
  42.         ' Draw a box with i <= X <= i + 1 and
  43.         ' 0 <= Y <= Data(i).
  44.         Line (i, 0)-(i + 1, DataValue(i)), , B
  45.     Next i
  46. End Sub
  47.